package com.userutils;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import com.userresponsedaos.WSResponseDAO;

public class WSConnectionFile{

	 
	public static String wsConn(Object obj_value,String obj_name,String methodname, String v_soapaction)
	{
		// connecting to web services 
        SoapObject obj_soapobject=new SoapObject(WSConnectionStrings.NAMESPACE, methodname);
        
        // passsing parameters to KSOAP
        obj_soapobject.addProperty(obj_name, obj_value); 
        
        // creating object for soap envelop 
       SoapSerializationEnvelope soapenvelope =new SoapSerializationEnvelope(SoapEnvelope.VER11);
       // assigning parameters to soap enevelop
       soapenvelope.setOutputSoapObject(obj_soapobject);  
        
       WSResponseDAO obj_resdto123=new WSResponseDAO();
       // invoking the webservice 
       try  
       {         
    	   AndroidHttpTransport obj_http=new AndroidHttpTransport(WSConnectionStrings.URL);
    	   obj_http.call(v_soapaction, soapenvelope);
    	    
    	   // Retrieving and parsing response from webservice
    	   SoapObject response = (SoapObject)soapenvelope.getResponse();
    	  // SoapObject pii = (SoapObject)response.getProperty(1);
    	  
    	   obj_resdto123.v_responsedata=response.getProperty(0).toString(); 
    	       
    	   System.out.println("the response is "+obj_resdto123.v_responsedata);
       }
       catch (Exception e)  
       {
		e.printStackTrace();         
	   }
        return obj_resdto123.v_responsedata;
	}
	
}
